package question4;


public class TestVisiteurCalcul extends junit.framework.TestCase{
	private Memoire m;
	@SuppressWarnings("unused")
	private Variable x,x1;
	
	public void setUp(){
	  m  = new Memoire();
	  x  = new Variable(m,"x",3);
	  x1 = new Variable(m,"x1",5);
	}
	 
	public void test_UneConstante(){
		Expression expr = new Constante(3);
    assertEquals(expr.accepter(new VisiteurCalcul(m)),new Integer(3));	
	}
	
	public void test_DeVariables(){
	  Memoire m1 = new Memoire();
		Expression expr = new Variable(m1,"i");
    assertEquals(expr.accepter(new VisiteurCalcul(m1)),new Integer(0));
    expr = new Variable(m1,"j",55);
    assertEquals(expr.accepter(new VisiteurCalcul(m1)),new Integer(55));
	}
	
	public void test_UneAddition1(){
		Expression expr = new Addition(new Constante(3), new Constante(2));
	  assertEquals(expr.accepter(new VisiteurCalcul(m)),new Integer(5));	
	}
	

	public void testFactoriel(){
	  assertEquals(m.lire("x1"),5);
	  assertEquals(new Factoriel(x1).accepter(new VisiteurCalcul(m)),new Integer(120));
	 }
	
	 
}
